import { getLevelFirst, getLevelZero, getUserID } from '@/utils';

/**采购寻源意向公开管理权限*/
const SourceManageTabSwitch = (curRes: Record<string, any>) => {
  const SourceManageTab = () => {
    if (curRes?.['/purchaseSourceIntentController/createCompanyID']) {
      return {
        createCompanyID: getLevelZero(),
        params: 'createCompanyID',
        key: 'ManageTabKey',
      };
    } else if (curRes?.['/purchaseSourceIntentController/createDepartmentID']) {
      return {
        createDepartmentID: getLevelFirst(),
        params: 'createDepartmentID',
        key: 'ManageTabKey',
      };
    } else if (curRes?.['/purchaseSourceIntentController/createrID']) {
      return {
        createrID: getUserID(),
        params: 'createrID',
        key: 'ManageTabKey',
      };
    }
  };

  const MySourceCheckTab = () => {
    if (curRes?.['/purchaseSourceIntentController/MyCheck']) {
      return {
        createDepartmentID: getLevelFirst(),
        params: 'createDepartmentID',
        key: 'MyCheckTabKey',
        state: 1,
      };
    }
  };

  return [
    {
      // title: '意向公开',
      // key: 'ManageTabKey',
      // visible:
      //   (curRes?.['/purchaseSourceIntentController/createCompanyID'] ||
      //     curRes?.['/purchaseSourceIntentController/createDepartmentID'] ||
      //     curRes?.['/purchaseSourceIntentController/createrID']) ??
      //   false,
      // md: 2,
      // sm: 24,
      // params: SourceManageTab(),
    },
    // {
    //   title: '我的审核',
    //   key: 'MyCheckTabKey',
    //   visible: curRes?.['/purchaseSourceIntentController/MyCheck'] ?? false,
    //   md: 2,
    //   sm: 24,
    //   params: MySourceCheckTab(),
    // },
  ];
};

/**意向公开权限*/
const getSourceTableQuery = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceIntentController/applyCompanyID']) {
    return {
      applyCompanyID: getLevelZero(),
      params: 'applyCompanyID',
      key: 'ManageTabKey',
    };
  } else if (curRes?.['/purchaseSourceIntentController/applyDepartmentID']) {
    return {
      applyDepartmentID: getLevelFirst(),
      params: 'applyDepartmentID',
      key: 'ManageTabKey',
    };
  } else if (curRes?.['/purchaseSourceIntentController/applyerID']) {
    return {
      applyerID: getUserID(),
      params: 'applyerID',
      key: 'ManageTabKey',
    };
  }

  return {};
};

export { SourceManageTabSwitch, getSourceTableQuery };
